package com.changgou.goods.dao;

import com.changgou.goods.pojo.Spec;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface SpecMapper extends Mapper<Spec> {

    /**
     * 根绝分类名称查询规格列表
     * @param category
     * @return
     */
    @Select("SELECT \n" +
            "*\n" +
            "FROM\n" +
            "`tb_spec` \n" +
            "WHERE `template_id` = (\n" +
            "SELECT  template_id\n" +
            "FROM `tb_category`\n" +
            "WHERE NAME = #{category} AND parent_id <> 0)")
    List<Map> findSpecByCategory(@Param("category")String category);
}
